<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>打牌</title>
	<link rel="stylesheet" href="/game/bootstrap/css/bootstrap.min.css">
	<link rel="stylesheet" href="/game/css/dizhuroom.css">
	<link rel="stylesheet" href="/game/css/layui.css">
	<script src="/game/js/hallimg.js"></script>
	<script src="/game/js/pokers.js"></script>
</head>
<body>
	<div id="poker-main">
		<div class="poker-panel">
			<div class="col-md-9" id="poker-left-panel">
				<div class="col-md-12 radio">
					<!-- <span id="radio" class="radio"><marquee>忘了爱~。~</marquee></span> -->
				</div>
				<div class="col-md-12 lmr-panel">
					<div class="enemy-user-left">
						<div class="user-enemy-a">
							<table>
								<tr><td><img class="enemy-head enemy-head-left" src="/game/img/chesspanelright.png" alt="asd"></td></tr>
								<tr><td id="enemy_nick_left">未加入</td></tr>
								<tr><td id="left_state"> </td></tr>
								<tr><td id="left_hand"> </td></tr>
								<tr><td><br></td></tr>
								<tr><td><img id="left_clock" src="/game/img/clock.png" class="clock"></td></tr>
								<tr><td><span id="left_time" class="enemy-count-time">15</span></td></tr>
							</table>
						</div>
					</div>
					<div class="middle-panel">
						<div class="col-md-12 three-pokers">
							
						</div>
						<div class="col-md-12 round-pokers">
							<span id="sheichude"></span>
							<ul id="round_now">
								
							</ul>
						</div>
					</div>
					<div class="enemy-user-right">
						<div class="user-enemy-b">
							<table>
								<tr><td><img class="enemy-head enemy-head-right" src="/game/img/chesspanelright.png" alt="asd"></td></tr>
								<tr><td id="enemy_nick_right">未加入</td></tr>
								<tr><td id="right_state"> </td></tr>
								<tr><td id="right_hand"> </td></tr>
								<tr><td><br></td></tr>
								<tr><td><img id="right_clock" src="/game/img/clock.png" class="clock"></td></tr>
								<tr><td><span id="right_time" class="enemy-count-time">15</span></td></tr>
							</table>
						</div>
					</div>
				</div>

				<div class="col-md-12 bottom-user">
					<div class="col-md-12 btn-play">
						<img id="my_clock" src="/game/img/clock.png" class="clock"> <span id="my_time">20</span>
						<img src="/game/img/btn_onready.png" id="btn-ready" class="btn-go">
						<img src="/game/img/btn_exit.png" id="btn_exit" class="btn-go">
						<img src="/game/img/btn_jiao.png" id="btn_jiao" class="btn-go">
						<img src="/game/img/btn_bujiao.png" id="btn_bujiao" class="btn-go">
						<img src="/game/img/btn_qiang.png" id="btn_qiang" class="btn-go">
						<img src="/game/img/btn_buqiang.png" id="btn_buqiang" class="btn-go">
						<img src="/game/img/btn_cp.png" id="btn_go" class="btn-go">
						<img src="/game/img/btn_pass.png" id="btn_pass" class="btn-go">
					</div>
					<div class="col-md-12 my-pokers-panel">
						<ul id="my-pokers-panel">
							
							
						</ul>
					</div>
				</div>
			</div>
			<div class="col-md-3" id="poker-right-panel">
				<div class="poker-me">
					<img src="/game/img/chesspanelright.png" alt=""> <br>
					<span>{{ $user_nick }}</span>
				</div>
				<div class="user-enemy">
					<table class="table table-default enemysinfos">
						
					</table>
				</div>
				<div class="user-chat">
					
				</div>
				<div class="form-group">
					<input type="text" id="chat_word" class="form-control">
				</div>
			</div>
		</div>
	</div>
</body>
	<script src="/game/js/jquery-1.11.1.min.js"></script>
	<script src="/game/js/layer.js"></script>
	<script src="/game/bootstrap/js/bootstrap.min.js"></script>
	<script>
		
		var user_nick = window.parent.user_nick;
		var isgaming = 'false'; 
		var isjiao = true;
		var dizhunick = '';
		var lasthand = '';
		//存放手中牌数组
		var mypokers = [];
		//预出的牌
		var myround = [];

		var enemy_left = '';
		var enemy_right = '';

		//追加聊天到列表
		function roommsgadd(info) {
			var temp = JSON.parse(info);
			$('.user-chat').append('<div class="chat-list"><b>'+temp.nick+' 说：</b><p>'+temp.msg+'</p></div>');
			$('.user-chat').scrollTop($('.user-chat')[0].scrollHeight);
		}

		//刷新房间
		function freshorder(info) {
			enemy_left = '';
			enemy_right = '';
			//找出对手的位置
			for (var i = 0; i < info[0].length; i++) {
				if (info[0][i].nick == user_nick) {
					if (i == 0) {
						if (typeof(info[0][i+1]) != 'undefined') {
							enemy_left = info[0][i+1].nick;
						}
						if (typeof(info[0][i+2]) != 'undefined') {
							enemy_right = info[0][i+2].nick;
						}
					} else if (i == 1) {
						if (typeof(info[0][i-1]) != 'undefined') {
							enemy_right = info[0][i-1].nick;
						}
						if (typeof(info[0][i+1]) != 'undefined') {
							enemy_left = info[0][i+1].nick;
						}
					} else if (i == 2) {
						if (typeof(info[0][i-2]) != 'undefined') {
							enemy_left = info[0][i-2].nick;
						}
						if (typeof(info[0][i-1]) != 'undefined'){
							enemy_right = info[0][i-1].nick;
						}
					}
					break;
				}
			}

			if (info[1].user_b_nick == enemy_left) {
				$('#enemy_nick_left').html(enemy_left);
				$('.enemy-head-left').attr('src','/game/img/chesspanelright.png');
			} else if (info[1].user_a_nick == enemy_left) {
				$('#enemy_nick_left').html(enemy_left);
				$('.enemy-head-left').attr('src','/game/img/chesspanelright.png');
			} else if (info[1].user_c_nick == enemy_left) {
				$('#enemy_nick_left').html(enemy_left);
				$('.enemy-head-left').attr('src','/game/img/chesspanelright.png');
			} else {
				enemy_left = '';
				$('#enemy_nick_left').html('未加入');
				$('.enemy-head-left').attr('src',nobody_png);
			}

			if (info[1].user_b_nick == enemy_right) {
				$('#enemy_nick_right').html(enemy_right);
				$('.enemy-head-right').attr('src','/game/img/chesspanelright.png');
			} else if (info[1].user_a_nick == enemy_right) {
				$('#enemy_nick_right').html(enemy_right);
				$('.enemy-head-right').attr('src','/game/img/chesspanelright.png');
			} else if (info[1].user_c_nick == enemy_right) {
				$('#enemy_nick_right').html(enemy_right);
				$('.enemy-head-right').attr('src','/game/img/chesspanelright.png');
			} else {
				enemy_right = '';
				$('#enemy_nick_right').html('未加入');
				$('.enemy-head-right').attr('src',nobody_png);
			}

			//追加玩家信息到状态列表
			$('.enemysinfos').html('');
			if (info[1].user_a_nick != 'off') {
				$('.enemysinfos').append('<tr><td>'+info[1].user_a_nick+'</td><td>'+info[1].user_a_point+'%</td><td>'+info[1].user_a_status+'</td></tr>');
			}
			if (info[1].user_b_nick != 'off') {
				$('.enemysinfos').append('<tr><td>'+info[1].user_b_nick+'</td><td>'+info[1].user_b_point+'%</td><td>'+info[1].user_b_status+'</td></tr>');
			}
			if (info[1].user_c_nick != 'off') {
				$('.enemysinfos').append('<tr><td>'+info[1].user_c_nick+'</td><td>'+info[1].user_c_point+'%</td><td>'+info[1].user_c_status+'</td></tr>');
			}

		}

		//初始化对局
		function gameinit(info) {
			$('#btn-ready').hide();
			window.parent.letsplay();
			isgaming = true;
		}

		//发牌了
		function fapaile(pokers) {
			$('#btn-ready').hide();
			for (var i = 0; i < pokers.length; i++) {
				var temp = '<li><img class="mypokers" src="'+eval(pokers[i].poker)+'" poker="'+pokers[i].poker+'" value="'+pokers[i].value+'"></li>';
				$('#my-pokers-panel').append(temp);
			}
		}

		//等待对手时间
		function waiting(nick) {
			if (enemy_left == nick) {
				if (typeof(timeb) != 'undefined') { clearInterval(timeb); }
				$('#right_clock').hide();
				$('#right_time').hide();
				$('#left_clock').show();
				$('#left_time').show();
				$('#left_time').html('20');
				timeb = setInterval(leftdaojishi,1000);
			} else if (enemy_right == nick) {
				if (typeof(timec) != 'undefined') { clearInterval(timec); }
				$('#left_clock').hide();
				$('#left_time').hide();
				$('#right_clock').show();
				$('#right_time').show();
				$('#right_time').html('20');
				timec = setInterval(rightdaojishi,1000);
			} else {
				$('#left_clock').hide();
				$('#left_time').hide();
				$('#right_clock').hide();
				$('#right_time').hide();
			}
		}

		//左边倒计时
		function leftdaojishi() {
			var t = $('#left_time').html();
			t = t - 1;
		    $('#left_time').html(t);
		    if(t==0){
		    	$('#left_clock').hide();
				$('#left_time').hide();
		        clearInterval(timeb);
		    }
		}

		//右边倒计时
		function rightdaojishi() {
			var t = $('#right_time').html();
			t = t - 1;
		    $('#right_time').html(t);
		    if(t==0){
		    	$('#right_clock').hide();
				$('#right_time').hide();
		        clearInterval(timec);
		    }
		}

		//叫不叫地主
		function jiaobujiao() {
			$('#btn_jiao').show();
			$('#btn_bujiao').show();
			$('#my_clock').show();
		    $('#my_time').show();
		    if (typeof(timea) != 'undefined') { clearInterval(timea) }
		    $('#my_time').html('20');
		    timea = setInterval(jiaodaojishi,1000);
		}

		//我的叫倒计时
		function jiaodaojishi() {
			var t = $('#my_time').html();
			t = t - 1;
		    $('#my_time').html(t);
		    if(t == 0){
		    	window.parent.wobujiao();
		    	$('.btn-play').children().hide();
		        clearInterval(timea);
		    }
		}

		//我的抢倒计时
		function qiangdaojishi() {
			var t = $('#my_time').html();
			t = t - 1;
		    $('#my_time').html(t);
		    if(t == 0){
		    	window.parent.wobuqiang();
		    	$('.btn-play').children().hide();
		        clearInterval(timea);
		    }
		}

		//我的出牌倒计时
		function chudaojishi() {
			var t = $('#my_time').html();
			t = t - 1;
		    $('#my_time').html(t);
		    if(t == 0){
		    	window.parent.wobuchu();
		    	$('.btn-play').children().hide();
		        clearInterval(timea);
		        for (var i = $('#my-pokers-panel').find('img').length - 1; i >= 0; i--) {
		    		if ($($('#my-pokers-panel').find('img')[i]).attr('bottom') == '20px') {
		    			$($('#my-pokers-panel').find('img')[i]).attr('bottom','0px');
		    		}
		    	}
		    }
		}

		//地主第一次出牌倒计时 不能不出的时候也走这里
		function diyicichu() {
			var t = $('#my_time').html();
			t = t - 1;
		    $('#my_time').html(t);
		    if(t == 0){
		    	var temppoker = $('#my-pokers-panel').find('img').last().attr('poker');
		    	var tempvalue = $('#my-pokers-panel').find('img').last().attr('value');
				$('.btn-play').children().hide();
		    	window.parent.wochupai([[temppoker, tempvalue]]);
		    	$('#my-pokers-panel').find('img').last().remove();
		        clearInterval(timea);
		    }
		}

		//有人不叫
		function tabujiao(nick) {
			if (enemy_left == nick) {
				$('#left_state').html('不叫');
			} else if (enemy_right == nick) {
				$('#right_state').html('不叫');
			}
		}

		//有人叫了
		function tajiaole(nick) {
			if (enemy_left == nick) {
				$('#left_state').html('叫地主');
			} else if (enemy_right == nick) {
				$('#right_state').html('叫地主');
			}
		}

		//没人肯要地主
		function nobodystandup() {
			window.location.reload();
		}

		//抢不抢地主
		function qiangbuqiang() {
			if (isjiao == true) {
				$('#btn_qiang').show();
				$('#btn_buqiang').show();
				$('#my_clock').show();
			    $('#my_time').show();
			    if (typeof(timea) != 'undefined') { clearInterval(timea) }
			    $('#my_time').html('20');
			    timea = setInterval(qiangdaojishi,1000);
			} else {
				window.parent.wobuqiang();
			}
		}

		//有人不抢地主
		function tabuqiang(nick) {
			if (enemy_left == nick) {
				$('#left_state').html('不抢');
			} else if (enemy_right == nick) {
				$('#right_state').html('不抢');
			}
		}

		//有人抢地主
		function taqiangle(nick) {
			if (enemy_left == nick) {
				$('#left_state').html('抢地主');
			} else if (enemy_right == nick) {
				$('#right_state').html('抢地主');
			}
		}

		//出牌了 然后开始倒计时
		function chupaile() {
			if (lasthand != user_nick) {
			    $('#btn_go').show();
			    $('#btn_pass').show();
		            $('#my_clock').show();
			    $('#my_time').show();
			    if (typeof(timea) != 'undefined') { clearInterval(timea) }
			    $('#my_time').html('20');
			    timea = setInterval(chudaojishi,1000);
			} else {
			    $('#btn_go').show();
		            $('#btn_pass').hide();
			    $('#my_clock').show();
			    $('#my_time').show();
			    if (typeof(timea) != 'undefined') { clearInterval(timea) }
			    $('#my_time').html('20');
			    timea = setInterval(diyicichu,1000);
			}
		}

		//谁出了牌
		function sheichude(nick) {
		    lasthand = nick;
		    $('#sheichude').html(nick);
		    if (nick != user_nick) {
			$('#sheichude').css('color','white');
		    } else {
			$('#sheichude').css('color','yellowgreen');
		    }

		    if (enemy_left == nick) {
			$('#left_hand').html('出牌了');
			$('#right_hand').html('');
		    } else if (enemy_right == nick) {
			$('#right_hand').html('出牌了');
			$('#left_hand').html('');
	            }	
		}

		//有人出了牌
		function chulepai(info) {
			$('.three-pokers').html('');
			var temp = [];
			$('#round_now').html('');
			jQuery.each(info, function(k, v){
				temp.push(v.value);
				$('#round_now').append('<li><img class="round-pokers" src="'+eval(v.poker)+'" poker="'+v+'" value="'+v.value+'"></li>');
			});
		}

		//有人不出牌
		function tabuchu(nick) {
			if (enemy_left == nick) {
				$('#left_hand').html('不出');
			} else if (enemy_right == nick) {
				$('#right_hand').html('不出');
			}
		}

		//地主是谁
		function dizhuis(nick) {
			dizhunick = nick;
			if (enemy_left == nick) {
				$('#left_state').html('地主');
				$('#left_state').css('color','#FD0005');
				$('#right_state').html('农民');
				$('#right_state').css('color','yellowgreen');
			} else if (enemy_right == nick) {
				$('#right_state').html('地主');
				$('#right_state').css('color','#FD0005');
				$('#left_state').html('农民');
				$('#left_state').css('color','yellowgreen');
			} else if (nick == user_nick) {
				$('#left_state').html('农民');
				$('#right_state').html('农民');
				$('#left_state').css('color','yellowgreen');
				$('#right_state').css('color','yellowgreen');
				//地主必须出牌
				$('#btn_go').show();
				$('#my_clock').show();
			    $('#my_time').show();
			    $('#my_time').html('20');
			    if (typeof(timea) != 'undefined') { clearInterval(timea) }
			    timea = setInterval(diyicichu,1000);
			}
		}

		//服务器校验出牌OK
		function chupaiok(poker)
		{
			if (typeof(timea) != 'undefined') {
				clearInterval(timea);
			}
			
			jQuery.each(poker, function(k,v){
				for (var k = $('#my-pokers-panel').find('img').length - 1; k >= 0; k--) {
	    			if($($('#my-pokers-panel').find('img')[k]).attr('poker') == v) {
	    				$($('#my-pokers-panel').find('img')[k]).remove();
	    			}
    			}
			});
    		
	    	$('.btn-play').children().hide();
	    	myround = [];
		}

		//拿到三张牌
		function sanzhang(info) {
			jQuery.each(info, function(k,v){
				var temp = '<img src="'+eval(k)+'" poker="'+k+'" value="'+v+'">';
				$('.three-pokers').append(temp);
			});
			if (dizhunick == user_nick) {
				var count = $('#my-pokers-panel').find('img').length;
				jQuery.each(info, function(k,v){
					var temp = '<img class="mypokers" src="'+eval(k)+'" poker="'+k+'" value="'+v+'">';
					if (v == 3) {
						$('#my-pokers-panel').append(temp);
						count ++;
					} else if (v == 100) {
						$(temp).insertBefore($('#my-pokers-panel').find('img')[0]);
						count ++;
					} else if (v == 99) {
						if ($($('#my-pokers-panel').find('img')[0]).attr('value') != 100) {
							$(temp).insertBefore($('#my-pokers-panel').find('img')[0]);
						} else {
							$(temp).insertAfter($('#my-pokers-panel').find('img')[0]);	
						}
						count ++;
					} else if (v >= $($('#my-pokers-panel').find('img')[0]).attr('value')) {
						$(temp).insertAfter($('#my-pokers-panel').find('img')[0]);
					} else if (v <= $($('#my-pokers-panel').find('img')[count-1]).attr('value')) {
						$(temp).insertAfter($('#my-pokers-panel').find('img')[count-1]);
					} else {
						for (var i = 0; i < count; i++) {
							if (v <= $($('#my-pokers-panel').find('img')[i]).attr('value') &&
								v >= $($('#my-pokers-panel').find('img')[i+1]).attr('value')) {
								$(temp).insertAfter($('#my-pokers-panel').find('img')[i]);
								count ++;
								break;
							}
						}
					}
				});
				
			}
			//绑定扑克牌选择事件
			bindpokerselect();
		}

	    $(document).ready(function(){

	    	document.ondragstart = function() { return false; };
			//$(document).bind("contextmenu",function(){return false;});
		    $(document).bind("selectstart",function(){return false;});

		    //不叫地主
		    $('#btn_bujiao').click(function(){
		    	isjiao = false;
		    	clearInterval(timea);
		    	$('.btn-play').children().hide();
		    	window.parent.wobujiao(); 
		    });

		    //叫地主
		    $('#btn_jiao').click(function(){
		    	clearInterval(timea);
		    	$('.btn-play').children().hide();
		    	window.parent.wojiao(); 
		    });

		    //不抢地主
		    $('#btn_buqiang').click(function(){
		    	clearInterval(timea);
		    	$('.btn-play').children().hide();
		    	window.parent.wobuqiang(); 
		    });

		    //抢地主
		    $('#btn_qiang').click(function(){
		    	clearInterval(timea);
		    	$('.btn-play').children().hide();
		    	window.parent.woqiang(); 
		    });

		    //出牌
		    $('#btn_go').click(function(){
                        myround = [];
			for (var i = $('#my-pokers-panel').find('img').length - 1; i >= 0; i--) {
		    	    if ($($('#my-pokers-panel').find('img')[i]).css('bottom') == '20px') {
		    		var poker = $($('#my-pokers-panel').find('img')[i]).attr('poker');
		    		var value = $($('#my-pokers-panel').find('img')[i]).attr('value');
		    		myround.push([poker,value]);
		    	    }
		    	}
		    	window.parent.wochupai(myround);
		    });

		    //不出牌
		    $('#btn_pass').click(function(){
		    	clearInterval(timea);
		    	$('.btn-play').children().hide();
		    	window.parent.wobuchu();
		    	for (var i = $('#my-pokers-panel').find('img').length - 1; i >= 0; i--) {
		    	    if ($($('#my-pokers-panel').find('img')[i]).css('bottom') == '20px') {
		    		$($('#my-pokers-panel').find('img')[i]).css('bottom','0px');
			    }
		    	}
		    });

		    $('#left_time').hide();
		    $('#right_time').hide();
		    $('#left_clock').hide();
		    $('#right_clock').hide();
		    $('#my_clock').hide();
		    $('#my_time').hide();
		    $('#btn_jiao').hide();
		    $('#btn_bujiao').hide();
		    $('#btn_go').hide();
		    $('#btn_pass').hide();
		    $('#btn_qiang').hide();
		    $('#btn_buqiang').hide();

		    //拿到房间信息
		    window.parent.getroominfo();

			//回车键发送事件
		 	$('#chat_word').keyup(function(event) {
		 		var event = arguments.callee.caller.arguments[0]||window.event;
				if (event.keyCode ==13) {
			 		var msg = $('#chat_word').val().replace(/[\r\n]/g,'');
			 		$('#chat_word').val('');
			 		if (msg.substr(0,10) == '') {
			 			return false;
			 		}
			 		window.parent.sendroomchat(msg);
				}
			});

			//退出房间
			$('#btn_exit').click(function(){
				window.parent.backhall();
			});

			//准备和取消准备
			$('#btn-ready').click(function(){
				if (this.value != 'ok') {
					this.value = 'ok';
					this.src = '/game/img/btn_readycancel.png';
					window.parent.mystatus = '准备';
					window.parent.pushreadystatus('pushreadystatus'+'ok');
					$('#btn_exit').hide();
				} else {
					this.value = 'no';
					this.src = '/game/img/btn_onready.png';
					window.parent.mystatus = '等待';
					window.parent.pushreadystatus('pushreadystatus'+'no');
					$('#btn_exit').show();
				}
			});

			$(document).mouseup(function(){
				$('.mypokers').unbind('mouseleave');
				$('.mypokers').unbind('mouseup');
			});

	    });

	    //绑定扑克牌选择事件方法
		function bindpokerselect() {
			//绑定扑克牌起落事件
		    $('.mypokers').mousedown(function(ev){
				$('.mypokers').mouseleave(function(ev){
					if ($(ev.target).css('bottom') == '20px') {
						$(ev.target).css('bottom', '0px');
					} else {
						$(ev.target).css('bottom', '20px');
					}
				});
				$('.mypokers').mouseup(function(ev){
					if ($(ev.target).css('bottom') == '20px') {
						$(ev.target).css('bottom', '0px');
					} else {
						$(ev.target).css('bottom', '20px');
					}
				});
			});

		    //绑定扑克牌鼠标松开事件
			$(document).mouseup(function(){
				$('.mypokers').unbind('mouseleave');
				$('.mypokers').unbind('mouseup');
			});
		}

		//游戏结束
		function gameover(info) {

			console.log(info);

			isgaming = false;

			if (typeof(timec) != 'undefined') {
				clearInterval(timec)
			}
			if (typeof(timea) != 'undefined') {
				clearInterval(timea);
			}
			if (typeof(timeb) != 'undefined') {
				clearInterval(timeb);
			}

			//隐藏所有工具
			allhide();
			var endstatus = '和局';
			var enemyleft = '';
			var enemyright = '';
			var enemyleftpokers = [];
			var enemyrightpokers = [];
			var winner = '';
			var loser = '';
			var ranout = '';

			if (typeof(info.ranout) != 'undefined') {
				loser = info.ranout;
				showendselect(winner, loser, endstatus, info.ranout);
				return;
			}

			//找出所有的LOSER
			for (var i = info.lose.length - 1; i >= 0; i--) {

				if (typeof(info.lose[i]) != 'undefined' && info.lose[i][0] == user_nick) {
					console.log(info.lose[i][0]);
					loser = loser + '&nbsp;' + user_nick;
					endstatus = '失败';
				}

				if (typeof(info.lose[i]) != 'undefined' && info.lose[i][0] == enemy_left) {
					enemyleft = info.lose[i][0];
					loser = enemyleft + '&nbsp;' + loser;
					for (var k = info.lose[i][1].length - 1; k >= 0; k--) {
						enemyleftpokers.push(info.lose[i][1][k]);
					}
				}

				if (typeof(info.lose[i]) != 'undefined' && info.lose[i][0] == enemy_right) {
					enemyright = info.lose[i][0];
					loser = enemyright + '&nbsp;' + loser;
					for (var t = info.lose[i][1].length - 1; t >= 0; t--) {
						enemyrightpokers.push(info.lose[i][1][t]);
					}
				}
			}

			//找出所有的Winner
			for (var i = info.win.length - 1; i >= 0; i--) {

				if (typeof(info.win[i]) != 'undefined' && info.win[i] == user_nick) {
					winner = winner + '&nbsp;' + user_nick;
					endstatus = '胜利';
				}

				if (typeof(info.win[i]) != 'undefined' && info.win[i] == enemy_left) {
					enemyleft = info.win[i];
					winner = winner + '&nbsp;' + enemyleft;
				}

				if (typeof(info.win[i]) != 'undefined' && info.win[i] == enemy_right) {
					enemyright = info.win[i]
					winner = winner + '&nbsp;' + enemyright;
				}
			}

			$('#end-user1').html(enemyleft);
			$('#end-user2').html(enemyright);

			for (var i = enemyleftpokers.length - 1; i >= 0; i--) {
				$('.end-user1').append('<img class="middel_poker" src="'+eval(enemyleftpokers[i])+'">');
			}
			for (var i = enemyrightpokers.length - 1; i >= 0; i--) {
				$('.end-user2').append('<img class="middel_poker" src="'+eval(enemyrightpokers[i])+'">');
			}

			showendselect(winner, loser, endstatus, ranout);
		}

		//弹出对局结果
		function showendselect(winner,loser, endstatus, ranout) {
			var thecolor = "white";
			var themsg = '<div style="padding: 50px; font-family: "黑体"; line-height: 22px; color: #fff; font-weight: 300;"><p style="text-align: center;font-size: 40px;color: '+thecolor+';font-weight:bold;">'+endstatus+'</p><br><br><p style="text-align: center;font-size: 20px;">Win：'+winner+'</p><br><p style="text-align: center;font-size: 20px;">Lose：'+loser+'</p></div>';

			if (endstatus == '胜利') {
				thecolor = 'yellowgreen';
			} else if (endstatus == '失败') {
				thecolor = '#FD0005';
			} else {
				thecolor = 'white';
				themsg = '<div style="padding: 50px; font-family: "黑体"; line-height: 22px; color: #fff; font-weight: 300;"><p style="text-align: center;font-size: 40px;color: '+thecolor+';font-weight:bold;">'+endstatus+'</p><br><br><p style="text-align: center;font-size: 20px;">打平了!</p></div>';
				if (ranout != "") {
					themsg = '<div style="padding: 50px; font-family: "黑体"; line-height: 22px; color: #fff; font-weight: 300;"><p style="text-align: center;font-size: 40px;color: '+thecolor+';font-weight:bold;">'+endstatus+'</p><br><br><p style="text-align: center;font-size: 20px;">'+ranout+'逃跑了!</p></div>';
				}
			}

			layer.msg(themsg, {
				btn: ['再来一局', '退出房间'],
				shade: 0.3,
				closeBtn: false,
				area: '400px;',
				time: 0,
				resize: false,
				btnAlign: 'c',
				type: 1,
				moveType: 1,
				success: function(layero) {
				    var btn = layero.find('.layui-layer-btn');
				    btn.find('.layui-layer-btn0').click(function(){
				     	window.location.reload();
				    });
				    btn.find('.layui-layer-btn1').click(function(){

				    	window.parent.backhall();
				    });
				}
			});
		}

		//隐藏对战元素
		function allhide() {
			$('.btn-play').children().hide();
			$('#left-clock').hide();
			$('#left-time').hide();
			$('#right-clock').hide();
			$('#right-time').hide();
		}

	</script>
</html>
